package com.lxyk.dao.student;

import com.lxyk.domain.Student;
import com.lxyk.domain.StudentVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface CommonDao {

    //根据班级id查询学生信息
    @Select("select student.*,classes.* from student,classes where student.cid=classes.id and refundFlag=0 and quitFlag=0 and student.cid=#{cid}")
    List<StudentVO> findStudentByCid(Integer cid);

    //根据班级id查询对应的班级学生信息
    @Select("select DISTINCT classes.* from student,classes where student.cid=classes.id and refundFlag=0 and quitFlag=0 and student.cid=#{cid}")
    StudentVO findClassByCid(Integer cid);

    //添加学生信息
    @Insert("insert into student values(null,#{name},#{gender},#{age},#{education},#{major},#{jobState},#{enrollTime},#{consultTeacher}," +
            "#{openCourses},#{payWay},#{money},#{idCard},#{buyId},#{orderId},#{phone},#{urgentPhone},#{address},#{computer}," +
            "#{info},#{objective},#{refundFlag},#{quitFlag},#{transferClass},#{transferDate},#{record},#{cid})")
    void addStudent(StudentVO vo);

    //根据id查询学生基本信息
    @Select("select * from student,classes where student.cid=classes.id and student.id=#{id}")
    StudentVO findStudentById(Integer id);

    //修改学生信息
    @Update("update student set name=#{name},age=#{age},gender=#{gender},education=#{education},major=#{major},jobState=#{jobState},objective=#{objective},enrollTime=#{enrollTime},consultTeacher=#{consultTeacher} where id=#{id}")
    void updateStudent(Student student);

    //根据id查询学生详情
    @Select("select * from student,classes where student.cid=classes.id and student.id=#{id}")
    StudentVO findDetailById(Integer id);

    //模糊条件查询
    List<StudentVO> findStudentByCondition(StudentVO vo);

}
